home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
038a
/
bas_int1.zip
/
CMD_LINE.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-06-26
|
2KB
|
61 lines
'=================================================================
'Date: 04-11-91
'From: BRENT ASHLEY
'Subj: ORIGINAL COMMAND LINE; preserving lower case
'Conf: QBASIC (62)
'The command line as entered at the DOS prompt, in all its mixed-case
'splendour, is found at offset &H81 of the program's PSP (Program Segment
'Prefix), with the length of the command string at offset &H80 of the
'PSP.
'
'Finding your PSP from within QuickBASIC entails Interrupt calls.
' ~~~~~~~~~
'That same area of the PSP, however, is also the default disk transfer
'area for the program (or is it the default File Control Block? - I don't
'have my references handy) At any rate, I suspect QB always defines its
'own DTAs and FCBs, so the data won't be overwritten, but this cannot
'always be guaranteed. It would be best, therefore, if you were to get
'this info, to get it as early in the program's execution as possible,
'especially before any file I/O.
'======================================================================
DECLARE FUNCTION CmdLine$ ()
DEFINT A-Z
' $INCLUDE: 'qb.bi'
PRINT "Here's the original command line:"
PRINT "["; CmdLine; "]"
END
FUNCTION CmdLine$
'
' CmdLine - returns original command line
'
DIM Regs AS RegType
STATIC CmdLen, CmdBuild$, i
'
' DOS Interrupt 21h service 62h returns the segment
' address of the running program's PSP in the bx register.
'
Regs.ax = &H6200
CALL Interrupt(&H21, Regs, Regs)
DEF SEG = Regs.BX
'
' The command line's length is found at offset 80h of the PSP
' and the actual command line starts at 81h
'
CmdBuild$ = ""
CmdLen = PEEK(&H80)
FOR i = 1 TO CmdLen
CmdBuild$ = CmdBuild$ + CHR$(PEEK(&H80 + i))
NEXT
'
' restore BASIC data segment and return data
'
DEF SEG
CmdLine$ = CmdBuild$
END FUNCTION